<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/register.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">企业注册</h1>
			<a class="mui-pull-right has btn_open">已有账号</a>
		</header>
		<div class="mui-content" id="app">
			<div class="header">
				<h1><span class="num">①</span><span>填写注册基本信息</span></h1>
				<span class="small_title">手机号码为账号以及账户名称</span>
			</div>
			<div class="input">

				<input type="number" onblur="check(this.value)" v-model="shoujihao" name="" id="mobile" placeholder="请输入手机号" />
				<!--<input type="number" name="" id="verify" placeholder="请输入验证码" />-->

				<input type="password" v-model="pass" id="password" placeholder="请输入登录密码" />
				<input type="password" v-model="pass1" id="password1" placeholder="请确认登陆密码" />
			</div>

			<div class="pact">

				<input v-model="danxuan" type="checkbox" id="pact_box" value="" />
				<label for="pact_box">
					<span class="text">已阅读 <span class="red">《注册使用协议》</span>并同意相关注册条款内容</span>
				</label>
			</div>

			<div class="footer">
				<button type="button" class="mui-btn mui-btn-blue mui-btn-block btn_open">确认注册</button>
			</div>
		</div>
	</body>

</html>

<script src="js/mui.min.js"></script>
<script src="js/vue.js"></script>
<script type="text/javascript">
	mui.init()
	var app = new Vue({
		el: '#app',
		data: {
			msg: '0',
			pass: "",
			pass1: "",
			shoujihao: "",
			danxuan: '',
		},
		methods: {
			xiaoyan: function() {
				var buer = true;
				if(this.pass !== this.pass1) {
					buer = false;
					console.log(this.pass, this.pass1)
					mui.toast('密码不一样')
				} else if(this.danxuan !== true) {
					buer = false;
					mui.toast('还未勾选协议')
				} else if(this.pass === '') {
					buer = false;
					mui.toast('请填写密码')
				} else if(this.shoujihao.length !== 11) {
					mui.toast('手机号错误')
					buer = false;
				}
				return buer;
			}
		}
	})

	mui("body").on('tap', '.btn_open', function() {
		if(this.innerText === '确认注册') {
			if(app.xiaoyan()) {
				var user = {
					genPhone: app.shoujihao,
					genPassword: app.pass1,
				};
				
				user = JSON.stringify(user)
				cun('shoujihao',app.shoujihao);
				cun('DATA', user);
				console.log(user)
				tiao('qiyezhuce2');
			}

		} else if(this.innerText === '已有账号') {
			tiao('qiyedenglu');
		}
	})

	//检查手机号是否注册
	function check(num) {
		mui.ajax(URL + 'meGeneralUser!isHas', {
			data: {
				id: num,
			},
			dataType: 'json', //服务器返回json格式数据
			type: 'post', //HTTP请求类型
			timeout: 10000, //超时时间设置为10秒；
			success: function(data) {
				if(!Number(data.msg)) {
					mui.toast('手机号已注册');
					mui('#mobile')[0].focus()

				}

			},
			error: function(xhr, type, errorThrown) {
				console.log(xhr)
			}
		});

	}
</script>